package org.cainiao.basic.reactive.create;

import reactor.core.publisher.Flux;

public class HandleTest {

    public static void main(String[] args) {
        HandleTest handleTest = new HandleTest();
        handleTest.test();
    }

    public void test() {
        Flux<String> alphabetFlux = Flux.just(-1, 30, 13, 9, 20)
            .handle((i, sink) -> {
                String letter = alphabet(i);
                if (letter != null) {
                    sink.next(letter);
                }
            });
        alphabetFlux.subscribe(System.out::println);
    }

    public String alphabet(int letterNumber) {
        if (letterNumber < 1 || letterNumber > 26) {
            return null;
        }
        return String.valueOf('A' + letterNumber - 1);
    }

}
